<?php

function filter($value , $sr, $rep = null){
    return preg_replace(
            (array)$sr, ($rep==null?array(''):$rep), $value
            );
}

function filterUrl($subject, $host){
    return preg_replace(
                array(
            '/#^[a-zA-Z0-9]+$/',
            '/javascript:.*/',
            '/gg:.*/',
            '/skype:.*/',
            '/mailto:.*/',
            '#http(s?)://(www\.+|.?)' . str_replace('www.', '', $host) . '#',
            '/\/$/',
            '/^\//',
            '/#.*/',
            '/\"/',
            '/\.\.\/|\.\//'
                ), array(
            '', '', '', '', '', '', '', '', '', '', ''
                ), $subject);
}

function findLink($content){
    
    $matches = array();
    
    preg_match_all('~(http://[^\s\"<>\']+)~ie', $content, $matches);
    
    $nodeList = array();
    
    foreach($matches[1] as $item){
        $nodeList[] = new NObject(array('href'=>$item));
    }
    
    $nlist = new NList($nodeList);
    
    return $nlist;
}
